#ifndef __EFFECT3DMANAGER_H__
#define __EFFECT3DMANAGER_H__
/////////////////
//include
/////////////////
#include"Device.h"
#include"DeviceContext.h"
#include"../Effekseer/Effekseer.h"
#include"../Effekseer/EffekseerRendererDX11.h"
#include"../Effekseer/EffekseerSoundXAudio2.h"
#include<map>
/////////////////
//const
/////////////////
const int MAX_EFFECT_COUNT = 2000;
/////////////////
//class
/////////////////
class Camera;
struct Effect3D
{
	Effect3D(Effekseer::Handle handle = Effekseer::Handle(),	Effekseer::Vector3D pos = Effekseer::Vector3D(),Effekseer::Manager* manager = NULL)
	{
		this->handle	= handle;
		this->pos		= pos;
		this->manager = manager;
	}
	void SetPos(Vector3D pos)
	{
		this->pos.X = pos.x;
		this->pos.Y = pos.y;
		this->pos.Z = pos.z;
		manager->SetLocation(handle,this->pos);
	}
	void SetRotate(const Vector3D& axis,float rot)
	{
		Effekseer::Vector3D tmp_axis = Effekseer::Vector3D(axis.x,axis.y,axis.z);
		manager->SetRotation(handle,tmp_axis,rot);
	}
	void Stop()
	{
		manager->StopEffect(handle);
		manager->StopRoot(handle);
	}
	bool GetIsEnable(){return manager->Exists(handle);}
	Effekseer::Handle GetHandle() const {return handle;}
private:
	Effekseer::Handle handle;
	Effekseer::Vector3D pos;
	Effekseer::Manager* manager;
};
class Effect3DManager
{
public:
	Effect3DManager(Device* device = NULL,DeviceContext* device_context = NULL,Camera* camera = NULL);
	~Effect3DManager();

	static	void Init();
	static	void ContentLoad(Device* device);
	static	void Update();
	static	void Draw(DeviceContext* device);
	static	void Load3dEffect(int index,std::wstring file_name);
	static	Effect3D* SetEffect(int index,Vector3D pos,float size = 1.0f);
	static void ReleaseEffect(Effect3D* effect);
	static	Effekseer::Matrix44 GetMat(const Matrix& mat);
	static	void AllStop();
private:
	static	Effekseer::Manager*				manager;
	static	EffekseerRenderer::Renderer*	renderer;
	static	EffekseerSound::Sound*			sound;
	static	Camera*							camera;
	static	Array<Effekseer::Effect*> effect_infos;
	static	Array<Effect3D*> effects;
	
};
#endif __EFFECT3DMANAGER_H__
